package com.oa.office.dao;

import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.apache.ibatis.annotations.UpdateProvider;
import org.apache.ibatis.type.JdbcType;

import com.oa.office.entity.Shar;

public interface SharMapper {
    @Delete({
        "delete from shar",
        "where id = #{id,jdbcType=INTEGER}"
    })
    int deleteByPrimaryKey(Integer id);

    @Insert({
        "insert into shar (id, shar_type, ",
        "creater, updater, ",
        "create_time, update_time, ",
        "spar, head, state, ",
        "shar_content)",
        "values (#{id,jdbcType=INTEGER}, #{sharType,jdbcType=VARCHAR}, ",
        "#{creater,jdbcType=VARCHAR}, #{updater,jdbcType=VARCHAR}, ",
        "#{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP}, ",
        "#{spar,jdbcType=VARCHAR}, #{head,jdbcType=VARCHAR}, #{state,jdbcType=INTEGER}, ",
        "#{sharContent,jdbcType=LONGVARCHAR})"
    })
    int insert(Shar record);

    @InsertProvider(type=SharSqlProvider.class, method="insertSelective")
    int insertSelective(Shar record);

    @Select({
        "select",
        "id, shar_type, creater, updater, create_time, update_time, spar, head, state, ",
        "shar_content",
        "from shar",
        "where id = #{id,jdbcType=INTEGER}"
    })
    @Results({
        @Result(column="id", property="id", jdbcType=JdbcType.INTEGER, id=true),
        @Result(column="shar_type", property="sharType", jdbcType=JdbcType.VARCHAR),
        @Result(column="creater", property="creater", jdbcType=JdbcType.VARCHAR),
        @Result(column="updater", property="updater", jdbcType=JdbcType.VARCHAR),
        @Result(column="create_time", property="createTime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="update_time", property="updateTime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="spar", property="spar", jdbcType=JdbcType.VARCHAR),
        @Result(column="head", property="head", jdbcType=JdbcType.VARCHAR),
        @Result(column="state", property="state", jdbcType=JdbcType.INTEGER),
        @Result(column="shar_content", property="sharContent", jdbcType=JdbcType.LONGVARCHAR)
    })
    Shar selectByPrimaryKey(Integer id);
    
    @Select({
        "select",
        "id, shar_type, creater, updater, create_time, update_time, spar, head, state, ",
        "shar_content",
        "from shar",
    })
    @Results({
        @Result(column="id", property="id", jdbcType=JdbcType.INTEGER, id=true),
        @Result(column="shar_type", property="sharType", jdbcType=JdbcType.VARCHAR),
        @Result(column="creater", property="creater", jdbcType=JdbcType.VARCHAR),
        @Result(column="updater", property="updater", jdbcType=JdbcType.VARCHAR),
        @Result(column="create_time", property="createTime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="update_time", property="updateTime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="spar", property="spar", jdbcType=JdbcType.VARCHAR),
        @Result(column="head", property="head", jdbcType=JdbcType.VARCHAR),
        @Result(column="state", property="state", jdbcType=JdbcType.INTEGER),
        @Result(column="shar_content", property="sharContent", jdbcType=JdbcType.LONGVARCHAR)
    })
    List<Shar> selectAllShar();

    @UpdateProvider(type=SharSqlProvider.class, method="updateByPrimaryKeySelective")
    int updateByPrimaryKeySelective(Shar record);

    @Update({
        "update shar",
        "set shar_type = #{sharType,jdbcType=VARCHAR},",
          "creater = #{creater,jdbcType=VARCHAR},",
          "updater = #{updater,jdbcType=VARCHAR},",
          "create_time = #{createTime,jdbcType=TIMESTAMP},",
          "update_time = #{updateTime,jdbcType=TIMESTAMP},",
          "spar = #{spar,jdbcType=VARCHAR},",
          "head = #{head,jdbcType=VARCHAR},",
          "state = #{state,jdbcType=INTEGER},",
          "shar_content = #{sharContent,jdbcType=LONGVARCHAR}",
        "where id = #{id,jdbcType=INTEGER}"
    })
    int updateByPrimaryKeyWithBLOBs(Shar record);

    @Update({
        "update shar",
        "set shar_type = #{sharType,jdbcType=VARCHAR},",
          "creater = #{creater,jdbcType=VARCHAR},",
          "updater = #{updater,jdbcType=VARCHAR},",
          "create_time = #{createTime,jdbcType=TIMESTAMP},",
          "update_time = #{updateTime,jdbcType=TIMESTAMP},",
          "spar = #{spar,jdbcType=VARCHAR},",
          "head = #{head,jdbcType=VARCHAR},",
          "state = #{state,jdbcType=INTEGER}",
        "where id = #{id,jdbcType=INTEGER}"
    })
    int updateByPrimaryKey(Shar record);
}